<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title>Wookmark Stamping Example</title>
  <meta name="description" content="An example how to use stamping with Wookmark">
  <meta name="author" content="Christoph Ono, Sebastian Helzle">

  <meta name="viewport" content="width=device-width,initial-scale=1">

  <!-- CSS Reset -->
  <link rel="stylesheet" href="../bower_components/normalize.css/normalize.css">

  <!-- Global CSS for the page and tiles -->
  <link rel="stylesheet" href="../css/main.css">

  <!-- Specific CSS for the example -->
  <style>
    /**
     * Grid items
     */
    #tiles li {
      -webkit-transition: all 0.3s ease-out;
         -moz-transition: all 0.3s ease-out;
           -o-transition: all 0.3s ease-out;
              transition: all 0.3s ease-out;
    }
  </style>

</head>

<body>

  <div>
    <header>
      <h1>Wookmark Stamping Example</h1>
      <p>The items with the 'stamped' descriptions keep their positions even if they are defined out of order in the code.</p>
      <p>Each number in the descriptions represent their real index in the html code.</p>
      <p>You can stamp the first item to the right by setting the direction option to 'right'.</p>
      <br>
      <p><a href="../index.html">Back to overview</a></p>
    </header>
    <br/>

    <div role="main">

      <ul id="container" class="tiles-wrap animated">
        <li>
          <img src="../sample-images/image_1.jpg" height="283" width="200">
          <p>(1)</p>
        </li>
        <li class="stamped-last">
          <img src="../sample-images/image_2.jpg" height="300" width="200">
          <p>(2) Stamped to be the last!</p>
        </li>
        <li>
          <img src="../sample-images/image_3.jpg" height="252" width="200">
          <p>(3)</p>
        </li>
        <li class="stamped-first">
          <img src="../sample-images/image_4.jpg" height="158" width="200">
          <p>(4) Stamped to be the first!</p>
        </li>
        <li>
          <img src="../sample-images/image_5.jpg" height="300" width="200">
          <p>(5)</p>
        </li>
        <li>
          <img src="../sample-images/image_6.jpg" height="297" width="200">
          <p>(6)</p>
        </li>
        <li>
          <img src="../sample-images/image_7.jpg" height="200" width="200">
          <p>(7)</p>
        </li>
        <li class="stamped-fourth">
          <img src="../sample-images/image_8.jpg" height="200" width="200">
          <p>(8) Stamped to be the fourth!</p>
        </li>
        <li>
          <img src="../sample-images/image_9.jpg" height="398" width="200">
          <p>(9)</p>
        </li>
        <li>
          <img src="../sample-images/image_10.jpg" height="267" width="200">
          <p>(10)</p>
        </li>
      </ul>

    </div>
  </div>

  <!-- include jQuery -->
  <script src="../bower_components/jquery/dist/jquery.min.js"></script>

  <!-- Include the imagesLoaded plug-in -->
  <script src="../bower_components/imagesloaded/imagesloaded.pkgd.min.js"></script>

  <!-- Include the plug-in -->
  <script src="../wookmark.js"></script>

  <!-- Once the page is loaded, initalize the plug-in. -->
  <script type="text/javascript">
    (function ($) {
      imagesLoaded('#container', function () {
        function comparatorIsStamped(a, b) {
          var $a = $(a), $b = $(b);
          // Check if tile should be the first one
          if (!$a.hasClass('stamped-first') && $b.hasClass('stamped-first'))
            return 1;
          // Check if tile should be the last one
          if ($a.hasClass('stamped-last') && !$b.hasClass('stamped-last'))
            return 1;
          // Check if tile should the fourth one
          if (!$a.hasClass('stamped-fourth') && $b.hasClass('stamped-fourth') && $a.index() >= 4)
            return 1;
          return -1;
        }

        var wookmark = new Wookmark('#container', {
          offset: 2, // Optional, the distance between grid items
          itemWidth: 210, // Optional, the width of a grid item
          comparator: comparatorIsStamped, // Used to sort the items
          direction: 'left' // Set this to 'right' if you want to stamp the 'stamped-first' item to the right
        });
      });
    })(jQuery);
  </script>

</body>
</html>
